package net.xdclass.strategy;

import org.apache.shardingsphere.api.sharding.standard.PreciseShardingAlgorithm;
import org.apache.shardingsphere.api.sharding.standard.PreciseShardingValue;

import java.util.Collection;

public class CustomTablePreciseShardingAlgorithm implements PreciseShardingAlgorithm <String>{
	@Override
	public String doSharding(Collection <String> collection, PreciseShardingValue <String> preciseShardingValue) {
		String targetName = collection.iterator().next();
		String value = preciseShardingValue.getValue();
		String codeSuffix = value.substring(value.length() - 1 );
		return targetName + "_" + codeSuffix;
	}
}
